
module.exports = {
    find:function(DB,attr){
        return new Promise((resolve,rej)=>{
            DB.find(attr,(errs,targets)=>{
                if(errs) rej(errs);
                resolve(targets);
            })
        })
    },
    findOne:function(DB,attr){
        return new Promise((resolve,rej)=>{
            DB.findOne(attr,(errs,target)=>{
                if(errs) rej(errs);
                resolve(target);
            })
        })
    },
    update:function(DB,attr,modify){
        // console.log(attr);
        // console.log(modify);
        return new Promise((resolve,rej)=>{
            DB.update(attr,modify,(err,updated)=>{
                if(err) rej(err);
                // console.log(updated);
                resolve(updated);
            });
        })
    },
    destroy:function(DB,attr){
        return new Promise((resolve,rej)=>{
            DB.destroy(attr,(err,deleted)=>{
                if(err) throw err;
                resolve(deleted);
            });
        })
    }
}
